module top_module(
    input in,
    input [3:0] state,
    output [3:0] next_state,
    output out); //

   	parameter	A = 4'b0001;
    parameter	B = 4'b0010;
    parameter	C = 4'b0100;
    parameter	D = 4'b1000;
    
    assign next_state[0] = state[0]&(~in) | state[2]&(~in);
    assign next_state[1] = state[0]&in | state[1]&in | state[3]&in;
    assign next_state[2] = state[1]&(~in) | state[3]&(~in);
    assign next_state[3] = state[2]&in;
        
    assign out = state[3];

endmodule
